<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<html>
	<head>
		<title>_菜鸟面单设计</title>

	</head>

	<body>
	<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">${titlePage}</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
		<div class="alert alert-success" id="message" style="display: none">
			<button data-dismiss="alert" class="close">
				×
			</button>
			<span id="content">增加成功</span>

		</div>
		<div class="form-horizontal">
		<fieldset>
			<input type="hidden" value="${logisticsCompany.id}"
				id="logisticsCompanys" name="logisticsCompanyId">
			<div class="form-group row">
				<div class="col-sm-4">
					<div class="input-group col-md-12">
						<label for="pmsprinters_corpLevel" class="input-group-text">
							公司:
						</label>
						<input type="text" id="logisticsCompanyName"
							name="logisticsCompanyName"
							value="${logisticsCompany.companyName}"
							class="form-control input-large required" minlength="3" readOnly="true" />
					</div>
				</div>
				<!--  菜鸟面单不区分客户
				<div class="col-sm-3">
					<div class="input-group col-md-12">
						<label for="pmsprinters_corpLevel" class="input-group-text">
							客户:
						</label>
						<select name="customers" id="customers" class="form-control">
							<c:forEach items="${customers }" var="obj">
								<option value="${obj.customerCode }">
									${obj.customerName }
								</option>
							</c:forEach>
						</select>
					</div>
				</div>
				 -->
				<c:if test="${areaGroups ne null }">
				<div class="col-sm-4">
					<div class="input-group col-md-12">
						<label for="pmsprinters_corpLevel" class="input-group-text">
							网点:
						</label>
						<select id="areaGroups" name="areaGroups" class="form-control">
					     <c:forEach items="${areaGroups}" var="obj">
						  <option value="${obj.groupCode}"
							<c:if test="${areaGroupCode eq obj.groupCode}">selected="selected"</c:if>>
							${obj.groupName}
						  </option>
					    </c:forEach>
			    	</select>
					</div>
				</div>
				</c:if>
				
				<div class="col-sm-4">
					<div class="input-group col-md-12">
						<label for="pmsprinters_corpLevel" class="input-group-text">
							快递单名称:
						</label>
						<input type="text" id="expressStyleName" name="styleName"
						class="form-control input-large required" minlength="3" />
							<span id="styleNameMessage"></span>
					</div>
				</div>
			</div>
			
							<script type="text/javascript">
	var imageSrcName = "";
	var width=1000;
    var height=600;
    var defineParam =[];
    var CaiNiaoDesign ;
	function addAjaxExpressStyle(ajaxTempString) {
		$.ajax({
			type : 'post',
			url : '${ctx}/v2/expressPrinting/addAjaxMailExpressStyle',
			data : 'areaGroupCode='+$("#areaGroups").val()+'&logisticsCompanyId=' + $("#logisticsCompanys").val()+ ajaxTempString,
			dataType : 'json',
			success : function(data) {
				    $("#content").html(data.content);
					$("#message").show();
					$(function() {
						setTimeout(function() {
							$("#message").hide();
						}, 6000);
					});
				
			},
			error : function() {

			}
		});
	}

		function valNumber(tempNumber){
		  var rex_one="^[1-9]+(.[0-9]{0,2})?$";
		  var result_one =tempNumber.match(rex_one);
		  if(result_one==null){
		    return false;
		  }
	   	   return true;
		}
		
	$(document)
			.ready(
					function() {
						initCNDesign();	
						var boxes = $("input[type='checkbox']",$("#selectNames"));
					    boxes.on("ifChanged", function(event){
							Moditify($(this));
						});

						$("#button_btn")
								.click(
										function() {
											var content = getCaiNiaoDesignContent();
											var expressStyleName = $("#expressStyleName").val();
											if (expressStyleName == "") {
												$("#styleNameMessage").html("<font color=\"red\">请填写模版名称</font>");
												$(function() {
													setTimeout(function() {
														$("#styleNameMessage").hide();
													}, 6000);
												});
												return;
											}
											var checkDefault = "mail";
											
											var expressWidth=$("#expressWidth").val();
											var expressHeight=$("#expressHeight").val();
											if(!valNumber(expressWidth)){
											   alert("请填入正确的长度");
											   $("#expressWidth").focus();
											   return;
											}else{
											 	expressWidth=expressWidth*100;
											}
											if(!valNumber(expressHeight)){
											   alert("请填入正确的宽度");
											   $("#expressHeight").focus();
											   return;
											}else{
											   expressHeight=expressHeight*100;
											}
											var temp = '&content=' + content
													+ '&expressStyleName='
													+ expressStyleName
													+ '&type='
													+ checkDefault
													+ '&imageSrcName='
													+ imageSrcName
													+'&expressWidth='
													+expressWidth
													+'&expressHeight='
													+expressHeight
													+'&cainiaoFlg=1'
													+'&defineParam='
													+defineParam.join(";");
				
											addAjaxExpressStyle(temp);
											//$("#button_btn").attr("disabled","disabled");
										});
										CNDisplayDesign("${logisticsCompany.companyCode}");
					});
					

</script>

			<div id="lodopDiv">

				<tags:printerLodop></tags:printerLodop>
				<div class="modal-footer bg-gray">
				<c:if test="${status eq 0 }">
					<input id="button_btn" class="btn btn-primary" type="button"
						value="增加" />
				</c:if>
				<c:if test="${status eq 1 }">
					<input id="button_btn" class="btn btn-primary" type="button"
						value="更新" />
				</c:if>
				&nbsp;
				<input id="cancel_btn" class="btn" type="button" value="返回"
					onclick="history.back()" />
					</div>
			</div>
		</fieldset>
		</div>
		</div>
		</div>
		</div>
		</div>
		</section>
	</body>
</html>
